@import "./photon.min.less";

@import "./base/colors";
@import "./base/typography";
@import "./base/reset";

@import "./components/buttons.less";
@import "./com/toolbar.less";
@import "./com/spinner.less";
@import "./components/modal.less";
@import "./builtin-pages/components/toast";

// TODO: shouldn't import each of these on all builtin pages
// just reference them in their respective HTML -tbv
@import "./builtin-pages/bookmarks";
@import "./builtin-pages/history";
@import "./builtin-pages/library";
@import "./builtin-pages/downloads";
@import "./builtin-pages/settings";
@import "./builtin-pages/profile";
@import "./builtin-pages/watchlist";
@import "./builtin-pages/components/links-list";
@import "./builtin-pages/components/close-btn";
@import "./builtin-pages/components/avatar";
@import "./builtin-pages/components/post-popup";
@import "./builtin-pages/components/autocomplete-results";
@import "./builtin-pages/components/dat-network-activity";

.window {
  position: initial;
}

.window-content.builtin {
  &:extend(.system-font);
  position: initial;
  background: #f7f7f7;
}

.builtin-wrapper {
  &:extend(.flex);
  justify-content: space-around;
  flex-wrap: wrap;
  width: 100%;
  height: 100vh;
  background: #f7f7f7;

  > em.empty {
    color: rgba(0,0,0,.7);
  }

  .subtitle-heading {
    &:extend(.flex);
    justify-content: space-between;
    font-weight: 400;
    font-size: .7rem;
    text-transform: uppercase;
    padding-bottom: 5px;
    letter-spacing: .15px;
    color: rgba(0,0,0,.75);

    &:not(:first-of-type) {
      margin-top: 40px;
    }

    .link {
      text-transform: initial;
      letter-spacing: 0;
      font-size: .775rem;
    }
  }

  .lined-heading {
    &:extend(.flex);
    position: relative;
    align-items: center;
    font-size: 1.15rem;
    margin-bottom: 25px;
    font-weight: 400;

    i {
      margin-right: 7px;
    }

    &:before {
      margin-right: 10px;
    }

    &:after {
      margin-left: 10px;
    }

    &:before,
    &:after {
      display: block;
      content: '';
      flex: 1;
      height: 1px;
      background: #eee;
    }

    .lined-heading-action {
      position: absolute;
      right: 0;
      top: 0;
      padding: 0 10px;
      background: #fff;

      .fa {
        font-size: 18px;

        &.fa-times {
          -webkit-text-stroke: 2px #fff;
        }
      }
    }
  }

  .ll-column-headings {
    &:extend(.flex);
    align-items: center;
    justify-content: flex-start;
  }

  .ll-row {
    &:extend(.flex);
    align-items: center;
    justify-content: flex-start;
    position: relative;
    align-items: center;
    padding: 0 15px;
    height: 40px;
    background: #fff;
    border: 1px solid rgb(230, 230, 230);

    &:not(:last-of-type) {
      border-bottom: 0;
    }

    .checkbox {
      position: absolute;
      right: -35px;
      margin: 0;
      padding: 0 10px;
      font-size: 1.15rem;

      .fa {
        opacity: 0;
        color: #ccc;
      }

      input {
        display: none;

        &:checked + .fa {
          opacity: 1 !important;
          color: shade(@green, 15%);
        }
      }
    }

    .buttons {
      &:extend(.flex);
      align-items: center;
      justify-content: flex-end;
      margin-left: auto;
      opacity: 0;
    }

    .link {
      &:extend(.flex);
      align-items: center;
      flex-wrap: nowrap;
    }

    &:hover {
      background: rgb(249, 249, 249);

      .buttons {
        opacity: 1;
      }

      .actions {
        background: rgb(249, 249, 249);
      }

      .checkbox .fa {
        opacity: 1;
      }
    }

    &.selected {
      background: fadeout(@blue, 90%);
      border-color: tint(@blue, 72%);

      + .ll-row {
        border-top: 1px solid tint(@blue, 72%);
      }

      &:hover {
        background: fadeout(@blue, 90%);
      }
    }

    .title {
      &:extend(.overflow-ellipsis);
      max-width: 450px;
      display: inline-block;
      margin-right: 5px;
      color: @color-text !important;
    }

    .url {
      &:extend(.overflow-ellipsis);
      max-width: 200px;
      margin-right: 20px;
      color: #999;
      font-weight: 300;
    }

    .actions {
      &:extend(.flex);
      align-items: center;
      line-height: 100%;
      position: absolute;
      right: 10px;
    }
  }

  .search-container {
    position: relative;
    width: 100%;
    height: 32px;
    max-width: ~"calc(100% - 100px)";
    z-index: 3;

    @media (min-width: 950px) {
      margin: 0 auto;
      max-width: 700px;
    }

    .filter-btn {
      position: absolute;
      left: ~"calc(100% + 3px)";
      top: 1px;

      .dropdown-items {
        right: -3px;
      }
    }

    .dropdown-items.filters {
      width: 200px;
    }

    .spinner,
    .close-btn,
    .search {
      position: absolute;
    }

    i.fa-search {
      position: absolute;
      left: 10px;
      top: 8.75px;
      color: rgba(0,0,0,.5);
    }

    .spinner {
      left: 8px;
      top: 8px;

      &.hidden {
        display: none;
      }
    }

    .close-btn {
      right: 7px;
      top: 7px;
    }

    input.search {
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      padding: 0 10px;
      padding-left: 27px;

      &:invalid + .close-btn {
        opacity: 0;
      }
    }
  }
}

.builtin-header {
  &:extend(.flex);
  align-items: center;
  justify-content: flex-start;
  position: relative;
  height: 55px;
  padding: 0 20px;
  background: #fff;

  .builtin-pages-nav {
    position: absolute;
    left: 20px;
    visibility: hidden;

    @media (min-width: 965px) {
      visibility: visible;
    }

    .dropdown-items {
      width: 165px;
    }

    h1 {
      font-size: .95rem;
      font-weight: 500;
    }

    i {
      margin-right: 3px;
    }
  }

  .actions {
    position: absolute;
    right: 20px;
    z-index: 0;
  }

  &.fixed {
    &:extend(.flex);
    flex-wrap: nowrap;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5000;
    border-bottom: 1px solid rgb(210, 210, 213);
    box-shadow: 0 2px 0 rgba(0,0,0,.025);

    > * {
      margin-bottom: 0;
    }
  }

  label {
    color: @color-text--muted;
    margin-right: 10px;
    margin-bottom: 0;
    font-weight: 400;
    line-height: 26px;
  }
}

.builtin-main,
.builtin-sidebar {
  display: block;

  @media (min-width: 1050px) {
    display: inline-block !important;
  }
}

.builtin-sidebar {

  .nav-item {
    display: inline-block;
    padding: 0 8px;
    color: fadeout(@color-text, 10%);
    cursor: pointer;
    border-radius: 2px;
    display: inline-block;
    margin-bottom: 20px;

    .fa {
      display: none;
    }

    &.active {
      background: @blue;
      color: #fff;
    }

    &:hover:not(.active) {
      color: @blue;
    }

    @media (min-width: 1050px) {
      display: flex;
      align-items: center;
      position: relative;
      height: 25px;
      padding: 7px 0;
      margin-bottom: 0;

      .fa {
        display: none;
        width: 12px;
        margin-left: -12px;
      }

      &:hover {

        .icon {
          color: inherit;
        }
      }

      &.active {
        color: @blue;
        font-weight: 500;
        background: none;

        .fa {
          display: block;
        }
      }
    }
  }

  @media (min-width: 1050px) {
    position: fixed;
    top: 75px;
    left: 15px;
    width: 200px;

    .section {
      margin-bottom: 40px;

      > div {
        padding: 0 20px;
      }

      h2 {
        padding: 1px 20px;

        &.clickable {
          cursor: pointer;
        }

        .icon {
          width: 9px;
          height: 9px;
          margin-left: 3px;

          * {
            fill: rgba(0,0,0,.25);
            transition: fill .1s ease;
          }
        }

        &:hover {

          .icon * {
            fill: rgba(0,0,0,.5);
          }
        }
      }
    }
  }

  .nav-item.sub-nav-item {
    margin-left: 15px;

    &.active {
      font-weight: 500;
      color: @color-text;
    }
  }
}

.builtin-main {
  width: 100%;
  max-width: 700px;
  padding: 75px 5px;
  height: 100%;

  @media (min-width: 725px) {
    padding: 75px 0;
  }

  > div:not(.builtin-sidebar) {
    margin-bottom: 25px;
  }

  .view {
    padding: 15px;
    background: #fff;

    &.empty {
      text-align: center;
      max-width: 600px;
      margin: auto;
      background: none;

      i {
        font-size: 60px;
        color: rgba(0,0,0,.15);

        &.fa-search {
          margin-bottom: 10px;
          -webkit-text-stroke: 3px #f7f7f7;
        }
      }

      .label {
        font-size: .95rem;
        margin-bottom: 5px;
      }

      p {
        color: @color-text--muted;
        font-weight: 300;
      }
    }

    p {
      margin-top: 0;

      &:last-child {
        margin-bottom: 0;
      }
    }

    a:not(.btn) {
      color: @blue;

      &:hover {
        text-decoration: underline;
      }
    }

    ul {
      list-style: disc;
      margin-left: 20px;
    }

    &.fullwidth {
      max-width: none;
    }
  }

  .module {
    background: #fff;
    border-radius: 2px;

    &:not(:last-of-type) {
      margin-bottom: 20px;
    }

    .module-heading {
      &:extend(.flex);
      align-items: center;
      justify-content: space-between;
      background: #fafafa;
      padding: 7px 10px;
      border: 1px solid #ddd;
      border-radius: 4px 4px 0 0;
      font-size: .85rem;
      font-weight: 500;

      i {
        margin-right: 5px;
      }
    }

    .module-content {
      padding: 15px;
      border-left: 1px solid #ddd;
      border-right: 1px solid #ddd;

      &.bordered {
        border-bottom: 1px solid #ddd;
      }

      .empty {
        color: @color-text--muted;
        padding: 0;
      }
    }

    table {
      border: 1px solid #ddd;
      border-radius: 2px;
      font-size: 12.5px;
      margin-bottom: 5px;

      tr {
        display:block;
        width: 100%;
        padding: 3px 10px;

        &:nth-child(2n+1) {
          background: #f7f7f7;
        }

        &:not(:last-child) {
          border-bottom: 1px solid #eee;
        }

        &:first-child {
          border-bottom: 1px solid #ddd;
        }
      }

      td {
        padding: 0;
      }

      th {
        display: block;
        width: 100%;
        font-weight: 600;
        padding: 0;
      }
    }

    .module-footer {
      &:extend(.flex);
      border: 1px solid #ddd;
      border-radius: 0 0 2px 2px;

      > div {
        flex-basis: 100%;
        text-align: center;
        font-weight: 500;
        padding: 10px;

        .value {
          font-size: .85rem;
          font-weight: 500;
        }

        .label {
          font-size: .8rem;
          color: rgba(0,0,0,.4);
        }

        &:not(:last-child) {
          border-right: 1px solid #ddd;
        }
      }

      &.two > div {
        flex-basis: 50%;
      }
    }

  }

  .section,
  .module {

    // h2:not(.subtitle-heading),
    h3:not(.subtitle-heading) {
      font-size: inherit;
      font-weight: 500;
      margin-bottom: 2px;
      margin-top: 25px;

      &.no-margin {
        margin: 0;
      }
    }
  }

  .section-heading,
  .module-heading {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 10px;
  }

  .section-content,
  .module-content {

    form {
      margin-top: 5px;
    }

    textarea,
    input[type="text"] {
      width: 370px;
    }

    .input-group {
      &:extend(.flex);
      align-items: center;

      h3 {
        margin-bottom: 5px;
      }

      .btn {
        margin-left: 5px;
      }

      &.radiolist {
        margin-bottom: 7px;

        input[type="radio"],
        input[type="checkbox"] {
          margin: 0;
        }

        input[type="text"] {
          flex: 1;
        }

        label {
          font-weight: 400;
          margin-bottom: 0;
        }

        label,
        input[type="radio"],
        input[type="checkbox"] {
          margin-right: 10px;
        }

        .btn {
          margin-left: auto;
        }
      }
    }

    .hint {
      padding-top: 10px;
      border-top: 1px dashed #ddd;
    }

    &.coming-soon {
      position: relative;

      &:before,
      &:after {
        &:extend(.flex);
        justify-content: center;
        align-items: center;
        position: absolute;
        left: 0;
        top: 0;
        content: '';
        width: 100%;
        height: 100%;
      }

      &:before {
        background: fadeout(#fff, 45%);
      }

      &:after {
        width: 160px;
        height: 30px;
        left: 50%;
        top: 50%;
        content: 'Coming soon';
        text-transform: uppercase;
        color: @color-text--muted;
        font-size: 1.3rem;
        letter-spacing: 1px;
        font-weight: 300;
        transform: translate(-50%, -50%) rotate(-15deg);
        text-shadow: 0 0 25px #fff;
      }
    }
  }
}

.builtin-hint {
  max-width: 450px;
  margin: 20px auto;
  color: rgba(0,0,0,.65);
  text-align: center;

  h2,
  h3 {
    font-size: inherit;
  }

  p {
    margin: 0;
  }
}

.learn-more,
.learn-more-link {
  font-size: .75rem;
  margin-left: 5px;
}

#builtin-loading-wrapper {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3000;
  width: 100%;
  height: 100%;
  background: none;

  .loading {
    &:extend(.flex);
    align-items: center;
    justify-content: center;
    width: 200px;
    margin: auto;
    margin-top: 20%;
    padding: 15px;
    border-radius: 4px;
    background: rgba(0,0,0,.7);
    color: fadeout(#fff, 8%);
    font-size: 16px;

    .spinner {
      display: inline-block;
      width: 22px;
      height: 22px;
      margin-right: 10px;
      color: fadeout(#fff, 8%);
    }
  }
}

.path-container {
  &:extend(.flex);
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 4px 2px 2px 4px;

  .btn {
    border: 0;
    border-left: 1px solid #dadada;
    border-radius: 0 2px 2px 0;
    height: 26px;
  }

  .path {
    &:extend(.code-font);
    flex: 1;
    height: 100%;
    line-height: 28px;
    padding: 0 7px;
    margin: 0;
    border: 0;
    font-size: 12.75px;
  }
}